%define _unpackaged_files_terminate_build 1

Summary: Cast screen
Name: doskast
License: GPL-3.0
Group: Graphical desktop/Other
Url: https://git.osmesh.ru/MOS/dosksast
Version: 0.1
Release: 1
Source0: %name-%version.tar
BuildArch: noarch
BuildRequires: make
BuildRequires: desktop-file-utils

%description
Cast screen

#--------------------------------------------------------------

%package board
Summary: Doskast for server (board)
Group: Graphical desktop/Other
Requires: %{_bindir}/inotifywait
Requires: xpra
Requires: apache2-base
Requires(pre): apache2-base

%description board
%summary

%files board
/var/www/cgi-bin/doskast-trigger-connect.cgi
%{_bindir}/doskast-server-watcher
%{_sysconfdir}/xdg/autostart/doskast-server-watcher.desktop
%attr(0775,root,apache2) /var/spool/doskast

#--------------------------------------------------------------

%package student
Summary: Doskast for client (student)
Group: Graphical desktop/Other
Requires: curl
Requires: xdpyinfo
Requires: xpra
Requires: zenity
Requires: %{_bindir}/pkexec

%description student
%summary

%files student
%{_bindir}/doskast-student-config
%{_bindir}/doskast-student-connect
%{_bindir}/doskast-xpra-shadow
%{_sbindir}/doskast-student-config
%{_unitdir}/doskast-xpra-shadow.service
%{_unitdir}/doskast-xpra-shadow.socket
%{_datadir}/applications/doskast-student-config.desktop
%{_datadir}/applications/doskast-student-connect.desktop
%{_datadir}/polkit-1/actions/ru.mos.doskast-student-config.policy
%{_sysconfdir}/xdg/autostart/doskast-xpra-shadow.desktop
%dir %{_sysconfdir}/systemd/system/doskast-xpra-shadow.service.d
%config(noreplace) %{_sysconfdir}/systemd/system/doskast-xpra-shadow.service.d/xpra-shadow-firewall.conf
%config(noreplace) %{_sysconfdir}/doskastrc

%post student
%post_service doskast-xpra-shadow.socket

%preun student
%preun_service doskast-xpra-shadow.service
%preun_service doskast-xpra-shadow.socket

#--------------------------------------------------------------

%prep
%setup -q

%build
%install
desktop-file-validate server-watcher/*.desktop
desktop-file-validate xpra-shadow/*.desktop
%makeinstall_std

mkdir -p %{buildroot}/var/spool/doskast
mkdir -p %{buildroot}%{_sysconfdir}
touch %{buildroot}%{_sysconfdir}/doskastrc
chmod 0644 %{buildroot}%{_sysconfdir}/doskastrc
